package main

import (
	"fmt"
	"golang.org/x/crypto/bcrypt"
)

func main() {
	bytes, err := bcrypt.GenerateFromPassword([]byte("123456"), bcrypt.DefaultCost)
	if err != nil {
		fmt.Println(err)
	}
	fmt.Println(string(bytes))

	err = bcrypt.CompareHashAndPassword(bytes, []byte("123456"))
	if err != nil {
		fmt.Println(err)
	} else {
		fmt.Println("解密成功")
	}
}
